The present invention relates to computer systems and more particularly to managing references to external objects in a run-time environment.
Computer languages that support independent constructed program units must resolve symbolic references from one program unit to an xe2x80x9cexternalxe2x80x9d object in another program unit. For example, most C and C++ programming language environments support separate compilation of source code files into object code files. When a source code file references an object defined in another source code file, the compiler typically creates an xe2x80x9cexternal referencexe2x80x9d to that object that is eventually resolved into an actual address.
A number of approaches have been developed for resolving external references. For example, with a xe2x80x9cstatic linkingxe2x80x9d approach, external references are resolved at link time, i.e. when the separately compiled object code files are combined together to form a complete, executable program. Another approach is xe2x80x9cdynamic linking,xe2x80x9d in which some object code files are grouped into modules typically called xe2x80x9cdynamic link librariesxe2x80x9d or xe2x80x9cDLLs.xe2x80x9d When a program linked with DLLs is executed, the DLLs are not combined with the program until the program is loaded into memory for execution. In the dynamic linking approach, external references are resolved at load time.
One popular programming language that supports separate compilation is JAVA, a platform-independent, object-oriented language developed by Sun Microsystems. In JAVA, the attributes and methods for a class of objects are typically defined in its own source file, which is separately compiled into an architecture-neutral object file containing bytecodes that are interpreted by the target platform. Since it is common for one class to reference objects belong to another class, JAVA source files will commonly require external references to other objects and their classes.
Lately, there has been much interest in using JAVA as a development language for applications that interact with a relational database system. A relational database system stores information in tables organized into rows and columns. To retrieve the information, a database application submits queries and other xe2x80x9ccallsxe2x80x9d to a database server process, which determines which information in the tables satisfies the request.
A multi-user database allows multiple users to connect to the database concurrently in many separate sessions, and typically only a few of the sessions are actively using the database at any particular time by making calls. When designing a run-time environment for database applications, scalability in terms of the number of simultaneous users who can establish separate sessions is very important. A significant constraint for user scalability is the size of the memory xe2x80x9cfootprintxe2x80x9d that each session consumes, and it is desirable to reduce the session memory footprint to improve scalability.
JAVA defines the lifetime of many objects, especially system objects, to extend throughout the duration of a session. Some of these objects, however, are infrequently used. Resolving external references to such objects at link time or load time according to conventional approaches entails loading these objects when the run-time environment is executed, either because they are statically part of the executable image or are dynamically loaded from a DLL. These objects consume session memory and reduce the user scalability of the database system.
Therefore, there is a need for improving the user scalability of a relational database system implementing a run-time environment for handling database applications. A need exists for reducing the session memory footprint consumed by infrequently used objects in a run-time environment. There also exists a need for resolving external references to objects without wasting session memory.
These and other needs are addressed by the present invention, in which lazy evaluation is systematically used for resolving recreatable external references. A recreatable external reference is a reference to an object whose state can easily be deallocated and later reconstituted or xe2x80x9cactivatedxe2x80x9d based on a much smaller sized descriptor. Lazy evaluation defers loading of the external object until the object is actually used, thereby reducing memory consumption. Deallocating and recreating external objects allows for the external objects to be allocated in non-session memories, which are less detrimental on user scalability.
One aspect of the invention pertains to a computer-implemented method and a computer-readable medium bearing instructions for managing memory for an object in a run-time environment. In accordance with this aspect, an external reference is created to the object based on a stub object in a session memory. The stub object indicates a descriptor for activating the object. The external reference is dereferences by allocating and initializing the object based on the descriptor in a non-session memory, i.e. having a duration other than that of a session, such as for the duration of a call or for the duration of a database instance. In various embodiments, the object is allocated and initialized the first time the object is dereferenced during a call and deallocated after termination of the call. Thus, the bulk of the memory required to store the state of the object is allocated without consuming valuable session memory.
Another aspect involves a computer-implemented method and computer-readable medium bearing instructions for creating an external reference to an object within a run-time environment, in which the object is associated with a stub object that indicates that the object is activatable and indicates a descriptor for activating the object. Accordingly, a pointer to a stub object is accessed, an index is generated for the object based on the descriptor indicated by the stub object, and the external reference is initialized to contain the index. In one embodiment, a value array at the index position is initialized to null, and the descriptor array at the index position is initialized with the descriptor for activating the object. Preferably, the external reference is tagged so that the external reference can be intermixed in the same environment with non-external references.
Still another aspect related to a computer-implemented method and computer-readable medium bearing instructions for dereferencing an external reference. An index is extracted from the external reference. A descriptor is fetched from an entry in a descriptor array at the position indicated by the index, and the object is allocated and initialized the object based on the descriptor. In one embodiment, a value array of cached activated objects is consulted first at the position indicated by the index.
Still other objects and advantages of the present invention will become readily apparent from the following detailed description, simply by way of illustration of the best mode contemplated of carrying out the invention. As will be realized, the invention is capable of other and different embodiments, and its several details are capable of modifications in various obvious respects, all without departing from the invention. Accordingly, the drawing and description are to be regarded as illustrative in nature, and not as restrictive.